-
Notifications
You must be signed in to change notification settings - Fork 39
feat: describe evaluation strategies of Tact #311
Conversation
|
||
### Binding strategy [#runtime-binding] | ||
|
||
Tact uses the [call by value (CBV)](https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_value) parameter-passing and binding strategy. That is, the evaluated value of any variable passed in a function call (except for [receivers](/book/contracts#receiver-functions) and [getters](/book/contracts#getter-functions)) or assigned in the [`let{:tact}`](/book/statements#let) or [assignment](/book/statements#assignment) statement is copied. This prevents mutations of the original values in different scopes, but increases the gas usage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also clarify that copying happens for structs and maps as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
The draft looks good! |
|
||
### Binding strategy [#runtime-binding] | ||
|
||
Tact uses the [call by value (CBV)](https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_value) parameter-passing and binding strategy. That is, the evaluated value of any variable passed in a function call (except for [receivers](/book/contracts#receiver-functions) and [getters](/book/contracts#getter-functions)) or assigned in the [`let{:tact}`](/book/statements#let) or [assignment](/book/statements#assignment) statement is copied. This prevents mutations of the original values in different scopes, but increases the gas usage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one missing piece though: mutating methods! Those cannot not copy their self
argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but those aren't part of the binding strategy, just as assignments to struct/message fields, map.set()/del()
, or any other re-assignments to local or state/storage variables. Like, the only things actively preventing re-assignments are constants :)
I can create a list of "allowed mutations" or say something about constants, not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about things like "small byte arrays"? tact-lang/tact#163 (comment)
Closing this in favor of re-opening in the tact-lang/tact repo where the docs migrated a while ago |
WIP: Need to move/refine examples of assignments and function calls from the playground contracts
Closes tact-lang/tact#1163
Towards tact-lang/tact#1097 (in some sense)